package view_parameter;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;

import controler.Controler;
import datenbank.ModelFormatteile;
import font.Schriften;

public class Formatteile extends JPanel {
	
	private ModelFormatteile modelFormatteile;
	private Controler controler;
	private JTable table;
	private JScrollPane scrollPane;
	private TableColumn col;
	private JLabel lblTitel;

	/**
	 * 
	 * @param controler
	 * @param modelFormatteile
	 */
	public Formatteile(Controler controler, ModelFormatteile modelFormatteile) {
		super(new BorderLayout(10, 10));

		this.modelFormatteile = modelFormatteile;
		this.controler = controler;

		initTable();

		initWidgets();

		addWidgets();
	}

	/**
	 * 
	 */
	private void initTable() {
		table = new JTable(modelFormatteile);

		table.getTableHeader().setFont(new Font("SansSerif", 1, 16));
		table.setRowHeight(20);
		table.setFont(new Font("SansSerif", 0, 14));

		table.setAutoResizeMode(0);

		col = table.getColumnModel().getColumn(0);
		col.setPreferredWidth(75);

		col = table.getColumnModel().getColumn(1);
		col.setPreferredWidth(150);

		col = table.getColumnModel().getColumn(2);
		col.setPreferredWidth(400);

		scrollPane = new JScrollPane(table);
		scrollPane.setHorizontalScrollBarPolicy(31);
		scrollPane.setPreferredSize(new Dimension(625, 0));
	}

	/**
	 * 
	 */
	private void initWidgets() {
		lblTitel = new JLabel("Formatteile Verwaltung");
		lblTitel.setFont(Schriften.fontTitel);
	}

	/**
	 * 
	 */
	private void addWidgets() {
		add("North", lblTitel);

		add("West", scrollPane);
	}
}